/**
 * File comment: complete
 */
package edu.gatech.oad.project.operations.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import edu.gatech.oad.project.coordinator.Office;
import edu.gatech.oad.project.operations.users.Nurse;

/**
 * Java representation of a treatment record.
 * A simple data structure.
 * 
 * @author Group 17
 * @version 1.0
 */
public class TreatmentRecord implements Serializable{

    
    /**
     * 
     */
    private static final long serialVersionUID = 5500031356153043933L;

    /**
     * Field nurse: the attending nurse of the
     * visit
     */
    private Nurse attendingNurse;
    
    /**
     * Field orders: the orders prescribed by
     * the above doctor
     */
    private DoctorOrders orders;
    
    /**
     * Field symptoms: the symptoms for the
     * patient, stored in a compound data struct
     */
    private List<String> symptoms;
    
    /**
     * Field vitalSigns: Information about the 
     * vitalSigns. Depending on what information
     * is measured, the vital signs is has a string
     * key (such as BloodPressure) and it stores the
     * integer. This may require more than one key.
     */
    private Map<String, Integer> vitalSigns;
    
    /**
     * Field diagnosis: the diagnosis for the 
     * patient
     */
    private String diagnosis;
    
    /**
     * Field myLogger: holds the logget for the office file
     */
    private static final Logger MYLOGGER = Logger.getLogger("edu.gatech." +
            "oad.project.operations.data");
    
    /**
     * Default constructor that sets single data types
     * to null and initializes compound data types
     */
    public TreatmentRecord(){

        this.attendingNurse = null;
        this.orders = new DoctorOrders();
        this.symptoms = new ArrayList<String>();
        this.vitalSigns = new HashMap<String, Integer>();
        this.diagnosis = null;
        
        MYLOGGER.addHandler(Office.FILEHANDLER);
        MYLOGGER.setLevel(Level.ALL);
        MYLOGGER.finest("treatment record created");
    }
    
    /**
     * Takes in a TreatmentRecord object and
     * copies over new fields to the actual
     * treatment data. NewRecord is just a temp
     * structure to easily pass multiple pieces
     * of data.
     *
     * @param newRecord updated record
     */
    public void update(TreatmentRecord newRecord) {
        final Nurse tempNurse;
        final DoctorOrders tempOrders;
        final String strTemp;
        final List<String> listStrTemp;
        final Map<String, Integer> mapTemp;
       
        tempNurse = newRecord.getAttendingNurse();
        if (tempNurse != null) {
            this.attendingNurse = tempNurse;
            MYLOGGER.info("updates attending nurse");
        }
        
        tempOrders = newRecord.getOrders();
        if (tempOrders != null) {
            this.orders = tempOrders;
            MYLOGGER.info("updates doctors orders");
        }
        
        strTemp = newRecord.getDiagnosis();
        if (strTemp != null) {
            this.diagnosis = strTemp;
            MYLOGGER.info("updates diagnosis");
        }
        
        listStrTemp = newRecord.getSymptoms();
        if (!listStrTemp.isEmpty()) {
            this.symptoms = listStrTemp;
            MYLOGGER.info("updates symptoms");
        }
        
        mapTemp = newRecord.getVitalSigns();
        if (!mapTemp.isEmpty()){
            this.vitalSigns = mapTemp;
            MYLOGGER.info("updates vital signs");
        }     
    }

    /**
    
     * @return the attendingNurse */
    public Nurse getAttendingNurse() {
        return attendingNurse;
    }

    /**
     * @param attendingNurse the attendingNurse to set
     */
    public void setAttendingNurse(Nurse attendingNurse) {
        this.attendingNurse = attendingNurse;
    }

    /**
    
     * @return the orders */
    public DoctorOrders getOrders() {
        return orders;
    }

    /**
     * @param orders the orders to set
     */
    public void setOrders(DoctorOrders orders) {
        this.orders = orders;
    }

    /**
    
     * @return the symptoms */
    public List<String> getSymptoms() {
        return symptoms;
    }

    /**
     * @param symptoms the symptoms to set
     */
    public void setSymptoms(List<String> symptoms) {
        this.symptoms = symptoms;
    }

    /**
    
     * @return the vitalSigns */
    public Map<String, Integer> getVitalSigns() {
        return vitalSigns;
    }

    /**
     * @param vitalSigns the vitalSigns to set
     */
    public void setVitalSigns(Map<String, Integer> vitalSigns) {
        this.vitalSigns = vitalSigns;
    }

    /**
    
     * @return the diagnosis */
    public String getDiagnosis() {
        return diagnosis;
    }

    /**
     * @param diagnosis the diagnosis to set
     */
    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }

    /**
     * String representation of a treatment record
     * 
    
     * @return the string */
    @Override
    public String toString() {
        return "TreatmentRecord [attendingNurse="
                + attendingNurse + ", orders=" + orders + ", symptoms="
                + symptoms + ", diagnosis=" + diagnosis + "]";
    }
    
    

}
